<style>
    table tr {
        height: 32px;
    }

    .switch {
        width: 28px;
        height: 14px;
    }

    .switch small {
        width: 14px;
        height: 14px;
    }

    .switch.checked small {
        left: 13px;
    }

    .dropdown-menu {
        max-height: 303px;
    }
</style>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <input type="text" ng-model="info.agent_ip" style="width: 220px;"
                           placeholder="Search Ucloud Ip Here..."/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <img src="/beetle/image/icon_plus-box.png"
                         ng-show="arrayContains(userRole, 'admin') || arrayContains(userRole, 'audit') || arrayContains(userRole, 'assign')"
                         ng-click="edit(i);" style="cursor: pointer;">
                </div>
                <div class="box-body" style=" ">
                    <table class="table table-hover table-bordered text-center">
                        <thead>
                        <tr>
                            <th>
                                操作
                            </th>
                            <th>
                                uCloud
                            </th>
                            <th>
                                冒烟结果
                            </th>
                            <th>
                                到期保留
                            </th>
                            <th>
                                项目
                            </th>
                            <th>
                                环境
                            </th>
                            <th>
                                状态
                            </th>
                            <th>
                                申请人
                            </th>
                            <th>
                                项目开始
                            </th>
                            <th>
                                项目结束
                            </th>
                            <th>
                                负载级别
                            </th>
                            <th>
                                实体机ip
                            </th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr ng-repeat="i in info.uclist |ucSearchFilter:info.agent_ip|paging:page.index:page.size track by $index">
                            <td>
                                <i class="glyphicon glyphicon-chevron-right i_class" data-ng-click="goucRelease(i);"
                                   uib-popover="部署应用" popover-trigger="mouseenter"></i>

                                <span ng-show="i.btnShow">
                                    <span ng-if="!isCEnv(i)">

                                        <i class="glyphicon glyphicon-cog i_class"
                                           ng-show="isUserCanOperateByRole('ucloud_admin')"
                                           data-ng-click="goToInitPage(i);" uib-popover="初始化"
                                           popover-trigger="mouseenter"></i>
                                        <i class="glyphicon glyphicon-tasks i_class"
                                           ng-show="isUserCanOperateByRole('ucloud_admin')"
                                           data-ng-click="goToProgressPage(i);" uib-popover="初始化进度"
                                           popover-trigger="mouseenter"></i>

                                        <!--<i class="glyphicon glyphicon-triangle-right i_class" ng-show="!vm.modifiable"-->
                                           <!--data-ng-click="recoverZoneApp(i);"-->
                                           <!--ng-if="isUserCanOperateByRole('ucloud_admin')"-->
                                           <!--uib-popover="停电恢复，启动停电前已经启动的应用" popover-trigger="mouseenter"></i>-->

                                        <i class="glyphicon glyphicon-triangle-right i_class" ng-show="!vm.modifiable"
                                           data-ng-click="importDb(i);" ng-if="isUserCanOperateByRole('ucloud_admin')"
                                           uib-popover="导入所有区域的数据库" popover-trigger="mouseenter"></i>

                                        <!--<i class="glyphicon glyphicon-triangle-right i_class" ng-show="!vm.modifiable"-->
                                           <!--data-ng-click="startZoneApp(i);"-->
                                           <!--ng-if="isUserCanOperateByRole('ucloud_admin')"-->
                                           <!--uib-popover="启动应用，默认启动中国、深圳、美国、美西" popover-trigger="mouseenter"></i>-->

                                        <i class="glyphicon glyphicon-triangle-right i_class" ng-show="!vm.modifiable"
                                           data-ng-click="initZoneApp(i);"
                                           ng-if="isUserCanOperateByRole('ucloud_admin')"
                                           uib-popover="安装所有区域的应用,更新成线上版本" popover-trigger="mouseenter"></i>

                                        <i class="glyphicon glyphicon-triangle-right i_class" ng-show="!vm.modifiable"
                                           data-ng-click="doAutoTest(i);" ng-if="isUserCanOperateByRole('ucloud_admin')"
                                           uib-popover="执行冒烟测试,部署完成应用后执行" popover-trigger="mouseenter"></i>

                                        <!--检查dump文件-->
                                        <!--<i class="glyphicon glyphicon-check i_class" data-ng-click="checkDump(i);"-->
                                        <!--ng-if="isUserCanOperateByRole('ucloud_admin') && !i.isRunning"-->
                                        <!--uib-popover="检查数据库文件是否正常" popover-trigger="mouseenter"></i>-->
                                        <!--<i class="glyphicon glyphicon-check i_class"-->
                                        <!--ng-if="isUserCanOperateByRole('ucloud_admin') && i.isRunning"-->
                                        <!--uib-popover="检查数据库文件是否正常" popover-trigger="mouseenter"-->
                                        <!--style="color: grey;"></i>-->
                                        <!--刷新dump文件更新时间-->
                                        <!--<i class="glyphicon glyphicon-refresh i_class"-->
                                        <!--data-ng-click="updateDumpTime(i);"-->
                                        <!--ng-if="isUserCanOperateByRole('ucloud_admin') && !i.isRunning"-->
                                        <!--uib-popover="刷新数据库文件更新时间" popover-trigger="mouseenter"></i>-->
                                        <!--<i class="glyphicon glyphicon-refresh i_class"-->
                                        <!--ng-if="isUserCanOperateByRole('ucloud_admin') && i.isRunning"-->
                                        <!--uib-popover="刷新数据库文件更新时间" popover-trigger="mouseenter"-->
                                        <!--style="color: grey;"></i>-->
                                        <i class="glyphicon glyphicon-wrench i_class" ng-show="!vm.modifiable"
                                           data-ng-click="edit(i);" ng-if="isUserCanOperateByRole('ucloud_admin')"
                                           uib-popover="编辑虚拟机信息" popover-trigger="mouseenter"></i>

                                        <!--<i class="glyphicon glyphicon-off i_class" data-ng-click="goRelease(i);"-->
                                        <!--uib-popover="启停agent" ng-if="arrayContains(info.userRole , 'admin')"-->
                                        <!--popover-trigger="mouseenter"></i>-->

                                        <!--<i class="glyphicon glyphicon-fast-forward i_class"-->
                                           <!--data-ng-click="gopostpone(i);"-->
                                           <!--ng-show="i.record_id != null" uib-popover="延期"-->
                                           <!--popover-trigger="mouseenter"></i>-->
                                        <i class="glyphicon glyphicon-fast-forward i_class"
                                           data-ng-click="keepAgent(i);"
                                           ng-show="i.record_id != null" uib-popover="申请在项目结束后保留机器7天"
                                           popover-trigger="mouseenter"></i>

                                        <i class="glyphicon glyphicon-fast-forward i_class" style="color: grey;"
                                           ng-show="i.record_id == null" uib-popover="没有分配的agent不需要延期"
                                           popover-trigger="mouseenter"></i>

                                        <i class="glyphicon glyphicon-trash i_class" data-ng-click="godel(i);"
                                           uib-popover="删除"
                                           ng-if="isUserCanOperateByRole('ucloud_admin')"
                                           popover-trigger="mouseenter"></i>

                                        <!--<i class="glyphicon glyphicon-refresh i_class" data-ng-click="goInitApp(i);"-->
                                        <!--uib-popover="初始化应用" ng-if="arrayContains(info.userRole , 'admin')"-->
                                        <!--popover-trigger="mouseenter"></i>-->

                                        <!--<i class="glyphicon glyphicon-cloud-download i_class" data-ng-click="goinit(i);"-->
                                        <!--uib-popover="安装/升级agent" ng-if="arrayContains(info.userRole , 'admin')"-->
                                        <!--popover-trigger="mouseenter"></i>-->

                                        <!--<i class="glyphicon glyphicon-circle-arrow-up i_class"-->
                                        <!--ng-show="i.record_id == null"-->
                                        <!--style="color: grey;" popover-trigger="mouseenter"></i>-->

                                        <!--<i class="glyphicon glyphicon-circle-arrow-up i_class"-->
                                        <!--ng-show="i.record_id != null && i.status != '申请刷新'"-->
                                        <!--data-ng-click="goupdate_agent(i);" uib-popover="申请升级"-->
                                        <!--popover-trigger="mouseenter"></i>-->

                                        <!--<i class="glyphicon glyphicon-circle-arrow-up i_class"-->
                                        <!--ng-show="i.record_id != null && i.status == '申请刷新'"-->
                                        <!--data-ng-click="cancel_update_agent(i);" uib-popover="取消升级申请"-->
                                        <!--popover-trigger="mouseenter"></i>-->
                                    </span>
                                </span>
                            </td>
                            <td>
                                <!--  <a id="configInfo" href="javascript:void(0)" class="btn-link" type="button" style="padding-left: 5%;" data-container="body" data-toggle="popover" data-placement="bottom" data-content="<p>ip:{{i.agent_ip}}</p><p>name:{{i.applicant_name}}</p>" data-html="true" data-trigger="focus">{{i.ip}}</a>
                             </td> -->
                                {{i.ip}}
                            <td>
                                <span ng-if="i.autoTestStatus == 'none'">无</span>
                                <span ng-if="i.autoTestStatus == 'running'">冒烟中</span>
                                <span ng-if="i.autoTestStatus == 'pass'" style="color: green;cursor: pointer;"><a
                                        ng-click="goToTestRestltHtml(i)">通过</a></span>
                                <span ng-if="i.autoTestStatus == 'fail'" style="color: red;cursor: pointer;"><a
                                        ng-click="goToTestRestltHtml(i)">不通过</a></span>
                            </td>
                            <td>
                                <span ng-if="i.isKeep == '0'" style="color: red;">是</span>
                                <span ng-if="i.isKeep != '0'">否</span>
                            </td>
                            <td>
                                {{i.plan_name}}
                            </td>
                            <td>
                                {{i.type}}
                            </td>
                            <td>
                                {{i.status}}
                            </td>
                            <td>
                                <a href="javascript:void(0);" uib-popover="点击查看延期记录" popover-trigger="mouseenter"
                                   ng-click="showPostponeinfo(i);">{{i.applicant_name}}</a>
                            </td>
                            <td>
                                {{i.start_date}}
                            </td>
                            <td>
                                {{i.expect_recover_date}}
                            </td>
                            <td>
                                {{i.level_name}}
                            </td>
                            <td>
                                {{i.machine_ip}}
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
                <uib-pagination total-items="info.uclist |ucSearchFilter:info.agent_ip|size" ng-model="page.index"
                                max-size="5"
                                previous-text="上一页"
                                next-text="下一页"
                                first-text="首页"
                                last-text="尾页"

                                items-per-page="page.size"

                                class="pagination-sm pull-right" boundary-links="true"></uib-pagination>
            </div>
        </div>
    </div>
</section>

<script type="text/ng-template" id="ucedit.html">
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header" style="margin-top:1px;">
                        <br>
                        <uib-accordion close-others="false">
                            <uib-accordion-group heading="" is-open="true">

                                <table>
                                    <tbody>
                                    <tr style="height: 70px;">
                                        <td> ip:</td>
                                        <td>
                                            <input type="text" ng-model="info.ip" name="" ng-disabled="istrue"
                                                   ng-change="testIp()"><span style="color:red;">{{info.codeMsg}}</span>
                                        </td>
                                    </tr>
                                    <tr style="height: 70px;"
                                        ng-show="info.plan_name!='' && info.plan_name!=undefined && info!=undefined">
                                        <td> 项目:</td>
                                        <td>
                                            <span>{{info.plan_name}}</span>
                                        </td>
                                    </tr>
                                    <tr style="height: 70px;"
                                        ng-if="info.applicant_name!='' && info.applicant_name!=undefined && info!=undefined">
                                        <td> 申请人:</td>
                                        <td>
                                            <span>{{info.applicant_name}}</span>
                                        </td>
                                    </tr>
                                    <tr style="height: 70px;"
                                        ng-if="info.start_date!='' &&info.start_date!=undefined && info!=undefined">
                                        <td> 申请日:</td>
                                        <td>
                                            <span>{{info.start_date}}</span>
                                        </td>
                                    </tr>
                                    <tr style="height: 70px;"
                                        ng-if="info.expect_recover_date!='' &&info.expect_recover_date!=undefined && info!=undefined">
                                        <td>回收:</td>
                                        <td>
                                            <span>{{info.expect_recover_date}}</span>
                                        </td>
                                    </tr>
                                    <tr style="height: 70px;">
                                        <td> 负载:</td>
                                        <td>
                                            <select ng-model="info.load_level" convert-to-number>
                                                <option value=>请选择</option>
                                                <option ng-repeat="x in level_list" value="{{x.id}}">{{x.level_name}}
                                                </option>
                                            </select>
                                        </td>
                                    </tr>
                                    <tr style="height: 70px;">
                                        <td> 实体机:</td>
                                        <td>
                                            <select ng-model="info.machine_ip">
                                                <option value="">请选择</option>
                                                <option ng-repeat="m in machine_list" value="{{m.ip}}">{{m.ip}}</option>
                                            </select>
                                        </td>
                                    </tr>
                                    <tr style="height: 70px;">
                                        <td>虚拟机id:</td>
                                        <td>
                                            <input type="text" ng-model="info.vm_id">
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </uib-accordion-group>
                        </uib-accordion>
                        <div class="modal-footer">
                            <button class="btn btn-warning" type="button" ng-click="save()" ng-disabled="info.ipLock">
                                save
                            </button>
                            <button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </section>

</script>


<script type="text/ng-template" id="postpone.html">
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header" style="margin-top:1px;">
                        <br>
                        <uib-accordion close-others="false">
                            <uib-accordion-group heading="" is-open="true">

                                <table width="95%">
                                    <tbody>

                                    <tr style="height: 70px;">
                                        <td>延期回收日期:</td>
                                        <td>
                                            <p class="input-group">
                                                <input clear-text="清除" close-text="关闭" current-text="今天"
                                                       ng-readonly="true"
                                                       type="text" class="form-control" uib-datepicker-popup
                                                       ng-model="info.to_date" is-open="endExceptTimeOpened"
                                                       ng-required="true" close-text="Close"/>
                                                <span class="input-group-btn">
                                                    <button type="button" class="btn btn-default"
                                                            ng-click="endExceptTimeOpened=!endExceptTimeOpened"><i
                                                            class="glyphicon glyphicon-calendar"></i></button>
                                                    </span>
                                            </p>
                                        </td>
                                    </tr>
                                    <tr style="height: 70px;">
                                        <td>描述</td>
                                        <td>
                                            <textarea style="width: 361px; height: 96px;"
                                                      ng-model="info.postpone_desc"></textarea>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </uib-accordion-group>
                        </uib-accordion>
                        <div class="modal-footer">
                            <button class="btn btn-warning" type="button" ng-click="save()">save</button>
                            <button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </section>

</script>

<script type="text/ng-template" id="postponeinfo.html">
    <style>
        .modal-content {
            width: 1350px;
            right: 380px;
        }
    </style>
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        延期记录
                    </div>
                    <div class="box-body">
                        <table class="table table-hover table-bordered text-center">
                            <thead>
                            <tr>
                                <th>申请人</th>
                                <th>申请时间</th>
                                <th>项目名称</th>
                                <th>旧回收日期</th>
                                <th>新回收日期</th>
                                <th>描述</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr ng-repeat="i in info.list">
                                <td>{{i.postpone_user_name}}</td>
                                <td>{{i.create_date| date:'yyyy-MM-dd HH:mm:ss'}}</td>
                                <td>{{i.plan_name}}</td>
                                <td>{{i.from_date}}</td>
                                <td>{{i.to_date}}</td>
                                <td>{{i.desc}}</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </section>
</script>